package com.situ.javase.day1;
import java.util.Scanner;

import org.junit.Test;

public class HomeWork {
	@Test
	public void test() {
		Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个数：");
        int num1 = scanner.nextInt();
        System.out.print("请输入第二个数：");
        int num2 = scanner.nextInt();
        System.out.println("第一个数是：" + num1);
        System.out.println("第二个数是：" + num2);
        // 两数交换
        int temp = num1;// 备份num1的值
        num1 = num2;
        num2 = temp; 
        System.out.println(num1);
        System.out.println(num2);
	}
	
	//交换两个数的值
	@Test
	public void test32() {
		System.out.println("请输入num1的值");
		Scanner scanner = new Scanner(System.in);
		int num1 = scanner.nextInt();
		System.out.println("请输入num2的值");
		int num2 = scanner.nextInt();
		System.out.println("num1的值是" + num1 + "num2的值是" + num2);
		// 交换
		num1 = num1 - num2;
		num2 = num2 + num1;
		num1 = num2 - num1;
		System.out.println("交换后num1的值是" + num1 + "num2的值是" + num2);
	}
	
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		//分别输入单价、数量、金额
		System.out.println("请输入商品单价：");
		double price = scanner.nextDouble();
		System.out.println("请输入商品数量：");
		double number = scanner.nextDouble();
		System.out.println("请输入收款金额：");
		double money = scanner.nextDouble();//money是顾客付的钱
		//allPrice是总的商品价格
		double allPrice = price*number;
		double stock = 0;//stock是找零
		double dazhe = 0;//dazhe是打折后的价格
		if ((allPrice >= 500) && (money < (allPrice*0.8) ) ){
			System.out.println("程序出现异常情况");
			return;
		}
		if ((allPrice < 500) && (money < allPrice)) {
			System.out.println("程序出现异常情况");
		    return;
		}
		
		if(money >= dazhe && allPrice>=500) {
			dazhe = allPrice*0.8;
			stock = money - dazhe;
			System.out.println("商品金额="+allPrice);
			System.out.println("应收金额="+dazhe);
			System.out.println("找零="+stock);
		}else {
			stock = money - allPrice;
			System.out.println("商品金额="+allPrice);
			System.out.println("应收金额="+allPrice);
			System.out.println("找零="+stock);
		}	
	}
	
	@Test
	public void test55() {
		double d1 = 3.14;
		double d2 = 3.15;
		System.out.println(d2 - d1);
		if (d2 - d1 == 0.01) {
			System.out.println("相等");
		}
	}
	
	@Test
	public void test56() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入单价：");
		// Alt+Shitf+L
		double price = scanner.nextDouble();
		System.out.println("请输入数量：");
		double count = scanner.nextDouble();
		System.out.println("请输入用户的金额：");
		double money = scanner.nextDouble();
		
		// 应收金额
		double totalPrice = price * count;
		if (totalPrice >= 500) {
			// totalPrice += 10;
			// totalPrice = totalPrice + 10;
			// totalPrice = totalPrice * 0.8;
			totalPrice *= 0.8;
		}
		
		// 找零
		double zhaoling = money- totalPrice;
		if (zhaoling >= 0) {
			System.out.println("应收金额" + totalPrice);
			System.out.println("找零：" + zhaoling);
		} else {
			System.out.println("付款金额不足");
		}
	}

}
